

class Base_Exception(BaseException):
    """自定义异常基类"""
    def __init__(self, message, context=None):
        super().__init__(message)
        self.context = context

class ExecutionException(Base_Exception):
    """执行过程异常"""
    def __init__(self, message, context=None):
        super().__init__(message, context)

class FileNotFoundException(Base_Exception):
    """文件未找到异常"""
    pass

class InvalidParameterException(Base_Exception):
    """参数无效异常"""
    pass

def execute_task(task_function, *args, **kwargs):
    """执行任务并捕获异常"""
    try:
        task_function(*args, **kwargs)
    except Exception as e:
        exception = ExecutionException(
            message="Error occurred during task execution.",
            context={"task": task_function.__name__, "args": args, "kwargs": kwargs},
        )
        Logger.log_exception(exception)
        ExceptionReporter.send_email(
            subject="Task Execution Failed",
            body=str(exception),
            recipient_email="admin@example.com"
        )
        raise exception

